package com.bondex.charter.controller;

import com.bondex.charter.po.*;
import com.bondex.charter.pojo.DetailPageOutT;
import com.bondex.charter.pojo.SearchParam;
import com.bondex.charter.service.SIService;
import com.bondex.global.pojo.PageTableParamT;
import com.bondex.global.pojo.ResultT;
import com.bondex.global.utils.JacksonUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Booking订舱页面相关接口
 * Created by JD on 2021/09/14.
 */
@Controller
@RequestMapping("/SI")
@Tag(name = "SI")
public class SIController extends BaseController {
	@Autowired
	private SIService sIService;

	@Operation(summary = "页面信息查询")
	@RequestMapping(value = "/getInfo", method = RequestMethod.GET)
	@ResponseBody
	public ResultT<DetailPageOutT<CharterSi, CharterSiUnconfirmed>> getInfo(HttpServletRequest request, HttpServletResponse response
			, @Parameter(description = "委托单号") String orderNo
	) {
		return sIService.getSiByOrderId(orderNo);
	}

	@Operation(summary = "编辑页面信息")
	@RequestMapping(value = "/updateBIInfo", method = RequestMethod.POST)
	@ResponseBody
	public String updateInfo(HttpServletRequest request, HttpServletResponse response
			, @RequestBody CharterSiSaveVO charterSiSaveVO) {
		return JacksonUtil.writeValue(sIService.saveBIInfo(charterSiSaveVO));
	}

	@Operation(summary = "格式单生成")
	@RequestMapping(value = "/cutOffSI", method = RequestMethod.POST)
	@ResponseBody
	public ResultT cutOffBillCreate(HttpServletRequest request, HttpServletResponse response
			, @RequestBody CharterReqSiForBusinessReq charterReqSiForBusinessReq) {
		return sIService.updateAndBillCreate(charterReqSiForBusinessReq);
	}

	@Operation(summary = "标记改单")
	@RequestMapping(value = "/amendmentBL", method = RequestMethod.POST)
	@ResponseBody
	public String amendmentBL(HttpServletRequest request, HttpServletResponse response
			, @Parameter(description = "查询条件") PageTableParamT<SearchParam> param
	) {
		return "";
	}

	@Operation(summary = "AMS申报")
	@RequestMapping(value = "/filingAMS", method = RequestMethod.POST)
	@ResponseBody
	public String filingAMS(HttpServletRequest request, HttpServletResponse response
			, @Parameter(description = "查询条件") PageTableParamT<SearchParam> param
	) {
		return "";
	}

	@Operation(summary = "提单签发")
	@RequestMapping(value = "/releaseBL", method = RequestMethod.POST)
	@ResponseBody
	public String releaseBL(HttpServletRequest request, HttpServletResponse response
			, @Parameter(description = "查询条件") PageTableParamT<SearchParam> param
	) {
		return "";
	}

	@Operation(summary = "历史操作")
	@RequestMapping(value = "/getHistoryInfo", method = RequestMethod.POST)
	@ResponseBody
	public String getHistoryInfo(HttpServletRequest request, HttpServletResponse response
			, @Parameter(description = "查询条件") PageTableParamT<SearchParam> param
	) {
		return "";
	}

	@Operation(summary = "历史状态")
	@RequestMapping(value = "/getHistoryStatus", method = RequestMethod.POST)
	@ResponseBody
	public String getHistoryStatus(HttpServletRequest request, HttpServletResponse response
			, @Parameter(description = "查询条件") PageTableParamT<SearchParam> param
	) {
		return "";
	}

	@Operation(summary = "台账标记改单操作")
	@RequestMapping(value = "/updateBIInfoForAmendmentList", method = RequestMethod.POST)
	@ResponseBody
	public String updateBIInfoForAmendmentList(HttpServletRequest request, HttpServletResponse response
			, @RequestBody CharterReqSiForBusinessListReq req) {

//		req.setOperatorId();
//		req.setUserName();
		return JacksonUtil.writeValue(sIService.handleBIInfoForAmendmentList(req));
	}

	@Operation(summary = "台账标记AMS申报操作-列表")
	@RequestMapping(value = "/updateBIInfoForAmsFilingList", method = RequestMethod.POST)
	@ResponseBody
	public String updateBIInfoForAmsFilingList(HttpServletRequest request, HttpServletResponse response
			, @RequestBody CharterReqSiForBusinessListReq charterSiForAmendmentReq) {
		return JacksonUtil.writeValue(sIService.handleBIInfoForAmsFilingList(charterSiForAmendmentReq));
	}

	@Operation(summary = "截单标记AMS申报操作-明细")
	@RequestMapping(value = "/updateBIInfoForAmsFiling", method = RequestMethod.POST)
	@ResponseBody
	public String updateBIInfoForAmsFiling(HttpServletRequest request, HttpServletResponse response
			, @RequestBody CharterReqSiForBusinessReq charterReqSiForBusinessReq) {
		return JacksonUtil.writeValue(sIService.updateBIInfoForAmsFiling(charterReqSiForBusinessReq));
	}

	@Operation(summary = "截单-明细更改通过/驳回")
	@RequestMapping(value = "/updateBIInfoForConfirm", method = RequestMethod.POST)
	@ResponseBody
	public String updateBIInfoForConfirm(HttpServletRequest request, HttpServletResponse response
			, @RequestBody CharterReqSiForBusinessListReq charterSiForAmendmentReq) {
		return JacksonUtil.writeValue(sIService.updateBIInfoForConfirm(charterSiForAmendmentReq));
	}

	@Operation(summary = "台账提单签发操作-列表")
	@RequestMapping(value = "/updateBIInfoForReleaseList", method = RequestMethod.POST)
	@ResponseBody
	public String updateBIInfoForReleaseList(HttpServletRequest request, HttpServletResponse response
			, @RequestBody CharterReqSiForBusinessListReq charterSiForAmendmentReq) {
		return JacksonUtil.writeValue(sIService.handleBIInfoForReleaseList(charterSiForAmendmentReq));
	}

	@Operation(summary = "截单提单签发操作-明细")
	@RequestMapping(value = "/updateBIInfoForRelease", method = RequestMethod.POST)
	@ResponseBody
	public String updateBIInfoForRelease(HttpServletRequest request, HttpServletResponse response
			, @RequestBody CharterReqSiForBusinessReq charterSiForAmendmentReq) {
		return JacksonUtil.writeValue(sIService.updateBIInfoForRelease(charterSiForAmendmentReq));
	}
}